package cn.com.pajx.pajx_visitor_v3.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.rcw.swiperefreshrecyclerview.BaseAdapter;
import com.rcw.swiperefreshrecyclerview.ViewHolder;

import java.util.List;

import cn.com.pajx.pajx_visitor_v3.R;
import cn.com.pajx.pajx_visitor_v3.bean.IntervieweeBean;
import cn.com.pajx.pajx_visitor_v3.utils.CommonUtil;

/**
 * Created by ruancw on 2024/2/28.
 * Description: pajx_visitor
 */
public class ChooseIntervieweeAdapter extends BaseAdapter<IntervieweeBean> {

    private OnFunctionListener onFunctionListener;

    public ChooseIntervieweeAdapter(Context context, int layoutId, List<IntervieweeBean> beans) {
        super(context, layoutId, beans);
    }

    @Override
    public void convert(ViewHolder holder, IntervieweeBean bean, int position) {
        ImageView ivAvatar = holder.getView(R.id.iv_avatar);
        TextView tvName = holder.getView(R.id.tv_name);
        TextView tvPhone = holder.getView(R.id.tv_phone);
        TextView tvChoose = holder.getView(R.id.tv_choose);
        tvName.setText(bean.getUser_name());
        tvPhone.setText(CommonUtil.hidePhoneNumber(bean.getUser_phone()));

        tvChoose.setOnClickListener(view -> {
            if (onFunctionListener != null) onFunctionListener.onChoose(bean);
        });
    }

    public interface OnFunctionListener {
        void onChoose(IntervieweeBean bean);
    }

    public void setOnFunctionListener(OnFunctionListener onFunctionListener) {
        this.onFunctionListener = onFunctionListener;
    }
}
